package translate;

import temp.Label;
import tree.BasicExp;
import tree.BasicStm;
import tree.LABEL;
import tree.SEQ;

public class IfThenExp extends Exp {
	Exp cond, tc;
	
	public IfThenExp(Exp c, Exp t) {
		cond = c; tc = t;
	}

	BasicStm unCx(Label tt, Label ff) {
		Label t = new Label();
		return new SEQ(cond.unCx(t, ff), new SEQ(new LABEL(t), tc.unCx(tt, ff)));
	}

	BasicExp unEx() {
		return null;
	}
	
	BasicStm unNx() {
		Label t = new Label();
		Label f = new Label();
		
		BasicStm tclause = new SEQ(new LABEL(t), new SEQ(tc.unNx(), new LABEL(f)));
		return new SEQ(cond.unCx(t, f), tclause);
	}

}
